<?php
include('wallet_db.html');
if (isset($from_page)) {
      $params[sid] = $sid;
      $params[action] = "home";
      $url = "$baseURL/$webDIR/?".encode_params($params);
      echo "<div style='padding: 4 4 4 4; text-align:right;'><a href='$url'>&laquo; Back to Home</a><br></div>";
}
?>
<table width="450">
  <tr>
    <td colspan=2><font class="text"><b><?=translate('store_name');?></b><br>
      <br>
      <?=translate('store_name_desc');?>
</font> </td>
  </tr>
</table>
<br>
<?
$params[sid] = $sid;
$params[action] = "editStoreName";
if (isset($from_page)) {
	$params['from_page'] = $from_page;
}
$url = "$baseURL/$webDIR/?".encode_params($params);
if (isset($_POST['form_sent']) && $_POST['form_sent'] == 'yes') {
	foreach ($_POST as $key => $value) {
		$_POST['$key'] = cleanup_input_text($value);
	}
	//------------------------------------------------------
		$sql['type']='UPDATE';
		$sql['params']="title = '".$_POST['store_name']."'";
		$sql['table']='stores';
		$sql['where']="reseller_id='$id' AND store_id = '".$_POST['control']."'";
		$sql['options']='';
		$sql['return']='';
	//------------------------------------------------------
	if (!$result=sql_exec($sql,$dbh81,'assoc')) {
		$errorMsg = translate('int_error');
		include_once('errorMsg.html');
		exit();
	} else {
		$okMsg = translate('successfully_changed_store_name');
		include_once('okMsg.html');
	}

}
//------------------------------------------------------
		$sql['type']='SELECT';
		$sql['params']='store_id,title';
		$sql['table']='stores';
		$sql['where']="reseller_id='$id'";
		$sql['options']='';
		$sql['return']='struct';
//------------------------------------------------------
if (!$result=sql_exec($sql,$dbh81,'assoc')) {
	$errorMsg = translate('int_error');
	include_once('errorMsg.html');
	exit();
}
$store_name = $result[0]['title'];
$store_id = $result[0]['store_id'];
?>
<br>
<TABLE border=1 class='bTable' cellspacing='0'>
  <form action='<?=$url;?>' method='POST'>
	<TR>
      <TH colspan='2'><?=translate('store_name');?></TH>
	</TR>
	<TR>
		<TD align='center'><?=translate('store_name');?>:
						<input type='text' name='store_name' value='<?=$store_name;?>'></TD>
	</TR>
	<TR>
		<TD  align='center' colspan='2'>
			<input type='submit' value='<?=translate('submit');?>'>
			<input type='hidden' name="form_sent" value="yes">
			<input type="hidden" name="control" value="<?=$store_id;?>">
		</TD>
	</TR>
</form>
</TABLE>

